<?php

class Connection {

    private static $db_host="localhost";
    private static $db_name="monitor_db";
    private static $username="root";
    private static $password="";

    private static $conn = null;

    public static function getConnection($selectDefaultDb = true) {
        if (self::$conn === null) {
            $dbName = $selectDefaultDb ? self::$db_name : '';
            self::$conn = new mysqli(self::$db_host,self::$username,self::$password,$dbName);
        }
        return self::$conn;
    }

    public static function clearConnection() {
        self::$conn = null;
    }
}